<?php 
require(DOCUMENT_ROOT."/file/phpmailer/class.phpmailer.php");
class email{
	
	private  static $smtp='smtp.163.com';
	
	private static $user='wangxinhui.419@163.com';
	
	private static $pass='rabbit1988419';
	
	private static $host='smtp.163.com';
	
	private static $form='JRSAI.com';
	
	private static $name='JRSAI.com';
	
	private static  $phpmailer;
	
	private  function _auto(){
		//$email_config=get_config();
		self::$phpmailer=new PHPMailer(); 
		
		self::$phpmailer->IsSMTP(); // send via SMTP 
		
		self::$phpmailer->Host = self::$smtp; // SMTP servers 
		
		self::$phpmailer->SMTPAuth = true; // turn on SMTP authentication 
		
		self::$phpmailer->Username = self::$user; // SMTP username 注意：普通邮件认证不需要加 @域名 
		
		self::$phpmailer->Password = self::$pass; // SMTP password 
		
		self::$phpmailer->From = self::$form; // 发件人邮箱
		
		self::$phpmailer->FromName = self::$name; // 发件人 
		
		self::$phpmailer->CharSet = "utf-8"; // 这里指定字符集！
		
		self::$phpmailer->Encoding = "base64"; 
				
	}
		
	/**
	 * 发送邮件
	 *
	 * @param string $sendto_email  发送的邮箱
	 * @param string $subject　　　　主题
	 * @param string $body　　　　　　内容
	 * @param string $user_name　　　发件人的名字
	 * @return bool　
	 */
	public function sendto($sendto_email,$subject,$body,$user_name=''){
		
		self::_auto();
		
		self::$phpmailer->AddAddress($sendto_email,$user_name); // 收件人邮箱和姓名 
		
		self::$phpmailer->AddReplyTo(self::$form,self::$host); 		
		
		self::$phpmailer->Subject = $subject;
		//是否html
		self::$phpmailer->IsHTML(true); // send as HTML 
	
		self::$phpmailer->Body = $body;
		
		self::$phpmailer->AltBody ="text/html"; 

		return self::$phpmailer->Send(); 		
	}
	
	
}
?>